<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // 1.  注册页(输入数据)  => 跳转至登录   (注册页主要为了提供数据   直接打开登录 没有数据)
  // 2.  登录页 从url中获取传递的数据  =>解析成一个对象 {user,pwd,phone,email} 

  // 数据拆分(解析)
  // http://127.0.0.1:5500/day12/html/login.html?user=a123123&pwd=123123&phone=17386141517&email=1272071495%40qq.com

  // user=a123123&pwd=123123&phone=17386141517&email=1272071495%40qq.com

  // var data = {
  //     "user": "a123123",
  //     pwd: 123123
  //     phone: 123123
  //     email: 123123
  // }
  var str = location.search;
  console.log(str);
  if (str) {  //从注册页跳转过来  => 有数据
    var newStr = str.substr(1);
    console.log(newStr);
    var arr = newStr.split("&")
    console.log(arr);
    var date = {};
    for (i = 0; i < arr.length; i++) {
      // console.log(arr[i]);
      var newArr = arr[i].split("=");
      console.log(newArr);
      date[newArr[0]] = newArr[1]
      // date[newArr[1]] = newArr[1]

    }
    console.log(date);
  } else {
    location.href = ".login.html?user=" + user + "pwd=" + pwd + "phone=" + phone + "email=" + email;
  }

</script>

</html>